//
//  FindViewController.m
//  FangXinLang
//
//  Created by AJY on 16/9/18.
//  Copyright © 2016年 AJY. All rights reserved.
//

#import "FindViewController.h"

#import <JavaScriptCore/JavaScriptCore.h>

#import "SearchViewController.h"

@interface FindViewController ()<UIWebViewDelegate>

@property(nonatomic,strong)UIButton * searchBarbutton;

@end

@implementation FindViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addFindSearchBar];
    
    UIWebView * findWebView = [[UIWebView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    
    findWebView.delegate = self;
    
    [self.view addSubview:findWebView];
    
    NSString * httpStr = @"https://sinanews.sina.cn/sinanewsapp/discovery/v530.d.html";
    
    
    NSURL *url = [NSURL URLWithString:httpStr];
    
    NSURLRequest * request = [NSURLRequest requestWithURL:url];
    
    [findWebView loadRequest:request];
    
}


-(void)addFindSearchBar
{
    
    _searchBarbutton = [[UIButton alloc]initWithFrame:CGRectMake(10, 22, [UIScreen mainScreen].bounds.size.width-10, 20)];
    
    [_searchBarbutton setTitle:@"#请输入关键词" forState:UIControlStateNormal];
    
    self.navigationItem.titleView = _searchBarbutton;
    
    _searchBarbutton.backgroundColor = [UIColor redColor];
    
    [_searchBarbutton setImage:[UIImage imageNamed:@"detail_search_icon"] forState:UIControlStateNormal];
    
    [_searchBarbutton addTarget:self action:@selector(jump:) forControlEvents:UIControlEventTouchUpInside];
    
    
}

-(void)jump:(UIButton *)sender{
    SearchViewController * search = [[SearchViewController alloc]init];
    
    search.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:search animated:YES];
}

@end
